package com.fadadianqi.logistics.admin.staff.dao.ibatis;

import com.fadadianqi.logistics.admin.staff.dao.MasterGroupDAO;
import com.fadadianqi.logistics.admin.staff.model.MasterGroup;
import com.fadadianqi.commons.GenericDAOSuport;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class MasterGroupDAOImpl extends GenericDAOSuport<String, MasterGroup>
        implements MasterGroupDAO {

    @Override
    public MasterGroup getWithMasterIdAndGroupId(String masterId,
                                                 String groupId) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("masterId", masterId);
        map.put("groupId", groupId);
        return super.getByPropertys(map);
    }

    @Override
    public List<MasterGroup> findByMasterId(String masterId) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("masterId", masterId);
        return super.findByPropertys(map);
    }

    @Override
    protected Class<?> getObjectClass() {
        return MasterGroup.class;
    }

    @Override
    protected String getTableName() {
        return "master_group";
    }

    @Override
    public void delByMasterId(String masterId) {
        super.removeByProperty("masterId", masterId);
    }
}
